package xyz.bali16.module.article.service;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gitee.starblues.annotation.Supplier;
import xyz.bali16.module.article.entity.Comment;
import xyz.bali16.module.article.model.comment.CommentAddParam;
import xyz.bali16.module.article.model.comment.CommentPageParam;
import xyz.bali16.module.article.model.comment.CommentUpdateParam;

/**
 * @author bali2 on 27/2/2022.
 * @version 1.0
 */
@Supplier("comment")
public interface CommentService extends IService<Comment> {

    /**
     * 根据评论目标（类别、id）对评论进行分页查询
     * @param entityType
     * @param entityId
     * @return
     */
    IPage<Comment> getPage(CommentPageParam param);


    Comment getTopLikeCommentByEntity(Integer entityType, String entityId);

    Comment getTopAnswerCommentByEntity(String entityId);

    /**
     * 查询评论的数量
     * @param entityType
     * @param entityId
     * @return
     */
     Integer getCommentCount(Integer entityType, String entityId);

     Integer getUserCommentCount(String userId);

    /**
     * 添加评论（需要事务管理）
     * @param comment
     * @return
     */
    void addComment(CommentAddParam param) throws Exception;

    /**
     * 修改帖子的评论数量
     *
     * @param articleId    帖子id
     * @param commentCount
     */
    void updateArticleCommentCount(String articleId, Integer commentCount);

    /**
     * 更新评论内容
     * @param param
     * @throws Exception
     */
    void updateComment(CommentUpdateParam param) throws Exception;

    void delete(String commentId) throws Exception;

    @Supplier.Method("getYesterdayCount")
    Integer getYesterdayCount();

    @Supplier.Method("countComment")
    Integer countComment();

}
